package gitTest;
//aa
public class Test {
	String password;
	
	public Test() {
		
	}
	public void encrypt() {
		char[] chars=new char[password.length()];
		chars=password.toCharArray();
		for(int i = 0;i<=password.length()-1;i++) {
			chars[i]=(char)(chars[i]+(i+4));
		}
		char tem=chars[password.length()-1];
		chars[password.length()-1]=chars[0];
		chars[0]=tem;
		for (int i = 0;i<=Math.ceil((password.length()-1)/2);i++) {
			char tem1=chars[i];	
            chars[i]=chars[password.length()-1-i] ;
            chars[password.length()-1-i]=tem1;
        }
		System.out.print("加密后的结果是：");
		for(int i = 0;i<=password.length()-1;i++) {
			System.out.print(chars[i]);
		}
		System.out.println(" ");
	}
	public void decrypt() {
		char[] chars=new char[password.length()];
		chars=password.toCharArray();
		for (int i = 0;i<=Math.ceil((password.length()-1)/2);i++) {
			char tem1=chars[i];	
            chars[i]=chars[password.length()-1-i] ;
            chars[password.length()-1-i]=tem1;
        }		
		char tem=chars[password.length()-1];
		chars[password.length()-1]=chars[0];
		chars[0]=tem;
		for(int i = 0;i<=password.length()-1;i++) {
			chars[i]=(char)(chars[i]-(i+4));
		}
		System.out.print("解密后的结果是：");
		for(int i = 0;i<=password.length()-1;i++) {
			System.out.print(chars[i]);
		}
		System.out.println(" ");
	}
	public void judge() {
		char[] chars=new char[password.length()];
		chars=password.toCharArray();
		int a1=0,a2=0,a3=0,a4=0;
		if(password.length()>=8) {
			 a1=1;
		}
		for(int i=0;i<=password.length()-1;i++) {
			if(48<=chars[i]&&chars[i]<=57) {
				 a2=1;
			}
			if(65<=chars[i]&&chars[i]<=90) {
				 a3=1;
			}
			if(97<=chars[i]&&chars[i]<=122) {
				 a4=1;
			}
		}
			if(a1==0||(a1==1&&((a2==1&&a3==0&&a4==0)||(a2==0&&a3==1&&a4==0)||(a2==0&&a3==0&&a4==1)))) {
				System.out.println("低强度密码");
			}
			if(a1==1&&((a2==1&&a3==1&&a4==0)||(a2==1&&a3==0&&a4==1))) {
				System.out.println("中强度密码");
			}
			if(a1==1&&a2==1&&a3==1&&a4==1) {
				System.out.println("高强度密码");
			}
	}
//生成密码
	public void prodpwd(int n) {
		char[] chars=new char[n];
		for(int i=0;i<=n-1;i++) {
			double tem=Math.random();
			if(tem<=0.22) {
				chars[i]=(char)((1+tem)*100);
			}else if(0.48<=tem&&tem<=0.57||0.65<=tem&&tem<=0.90||0.97<=tem) {
				chars[i]=(char)(tem*100);
			}else
				i--;
		}
		System.out.print("随机生成的密码是：");
		for(int i = 0;i<=n-1;i++) {
			System.out.print(chars[i]);
		}
		System.out.println(" ");
	}
	public static  void show() {
		 	System.out.println("========================");
			System.out.println("   欢迎使用密码管理系统");
			System.out.println("========================");
			System.out.println("     请选择操作：");
			System.out.println("1.加密");
			System.out.println("2.解密");
			System.out.println("3.判断密码强度");
			System.out.println("4.密码生成");
			System.out.println("5.退出");
			System.out.print("请输入选项序号：");
	 }

}
